<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>检测函数或代码运行时长</title>
</head>

<body>
  <script>

    console.time('time');  //启动一个计时器来跟踪某一个操作的占用时长
    for (var i = 0; i < 10000000; i++) {
      i / 2;
    }
    console.timeEnd('time');   //停止计时器
  </script>
</body>

</html>